<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户性别分布统计</title>
    <link rel="stylesheet" type="text/css" href="layui/css/layui.css">
</head>
<body>

    <div id="user_sex" style="width: 800px; height: 600px;">

    </div>

<script type="text/javascript" src="layui/layui.js"></script>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/echarts.min.js"></script>
<script type="text/javascript">



    $.ajax({
        url:"/webapp/user/queryUserSexCount",
        type:"post",
        dataType:"json",
        success:function (result) {
            var man_count = result.man_count;
            var women_count = result.women_count;
            var chart = echarts.init(document.getElementById("user_sex"));
            //通过setOption方法设置图表的选项
            chart.setOption({
                title: {
                    text: '用户性别分布统计',
                    left: 'center'
                },
                tooltip: {
                    trigger: 'item',
                    formatter: '{a} <br/>{b} : {c} ({d}%)'
                },
                legend: {
                    orient: 'vertical',
                    left: 'left',
                    data: ['男', '女']
                },
                series: [
                    {
                        name: '性别',
                        type: 'pie',
                        radius: '66%',
                        center: ['50%', '50%'],
                        data: [
                            {value: women_count, name: '女'},
                            {value: man_count, name: '男'},
                        ],
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            });
        }

    });




</script>
</body>
</html>